package com.edgardeng.hello.controller;

import com.edgardeng.hello.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/api/user")
public class UserController {

    @RequestMapping("")
    public String orderList(){
        return "UserController userList";
    }

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private IOrderService orderService;

    private static final String applicationName = "SpringCloud-OrderSevice";

    @RequestMapping(value = "order/feign")
    public Object feignRequest(){
        String s = orderService.list();
        return s;
    }

    @RequestMapping(value = "order/common")
    public Object commonRequest(){
        String url = "http://"+ applicationName +"/api/order";
        String s = restTemplate.getForObject(url, String.class);
        return s;
    }



}
